import java.io.Serializable;

/**
 * 商品实体类，实现序列化接口以支持对象持久化
 */
public class Product implements Serializable {
    // 序列化版本号（固定值，确保反序列化兼容性）
    private static final long serialVersionUID = 123456789L;

    private String id;       // 商品ID
    private String name;     // 商品名称
    private double price;    // 商品价格
    private int stock;       // 商品库存

    // 构造方法
    public Product(String id, String name, double price, int stock) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.stock = stock;
    }

    // Getter和Setter方法
    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public double getPrice() { return price; }
    public void setPrice(double price) { this.price = price; }
    public int getStock() { return stock; }
    public void setStock(int stock) { this.stock = stock; }

    // 重写toString用于打印商品信息
    @Override
    public String toString() {
        return "商品ID：" + id +
                "，名称：" + name +
                "，价格：" + price +
                "，库存：" + stock;
    }
}